package com.base.component;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;

public class BaseAction
{
   
    public static final String SUCCESS = "success";
    public static final String ERROR = "error";

    public static final String REDIRECT = "redirect";

    private String forward_page;

    private String redirect_page;
    
    /**
     * request.setAttribute
     */
    public BaseAction addAttr(String key, Object value)
    {
        @SuppressWarnings("unchecked")
		Map<String, Object> request = (Map<String, Object>) ActionContext
                .getContext().get("request");
        request.put(key, value);
        return this;
    }

    /**
     * forward
     */
    public String forward(String viewPath)
    {
        forward_page = viewPath;
        return SUCCESS;
    }
    public String error(String viewPath)
    {
    	forward_page = viewPath;
        return ERROR;
    }
    /**
     * redirect
     */
    public String redirect(String viewPath)
    {
        redirect_page = viewPath;
        return REDIRECT;
    }

    public String getForward_page()
    {
        return forward_page;
    }

    public String getRedirect_page()
    {
        return redirect_page;
    }

}
